package com.hzhq.contract.convert;

import com.hzhq.contract.bean.dto.CompanyDTO;
import com.hzhq.contract.bean.entity.Company;
import com.hzhq.contract.bean.vo.CompanyVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author: hzhq1255
 * @mail: hzhq1255@163.com
 * @date: 2021/4/13 15:56
 * @desc:
 */
@Mapper
public interface CompanyConvertBasic {

    CompanyConvertBasic INSTANCE = Mappers.getMapper(CompanyConvertBasic.class);

    CompanyDTO poToDto(Company source);

    Company dtoToPo(CompanyDTO source);

    @Mappings({
            @Mapping(target = "companyId", expression = "java(com.hzhq.contract.util.ConvertUtil.objectIdToString(source.getCompanyId()))")
    })
    CompanyVO dtoToVo(CompanyDTO source);

    @Mappings({
            @Mapping(target = "companyId", expression = "java(com.hzhq.contract.util.ConvertUtil.stringToObjectId(source.getCompanyId()))"),
            @Mapping(target = "deleted", expression = "java(com.hzhq.contract.status.DefaultValue.NOT_DELETED)")
    })
    CompanyDTO voToDto(CompanyVO source);
}
